package com.cxyzy.viewpager.showneighbour

import android.os.Bundle
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentPagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT

open class MainActivity : FragmentActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initViewPager()
    }

    private fun initViewPager() {
        val mPager: FlipViewPager = findViewById(R.id.flipViewPager)
        mPager.adapter = FlipFragmentAdapter(supportFragmentManager,
                BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT,this, PAGE_TITLES)
        mPager.setAnimationEnabled(true)
        mPager.setFadeEnabled(true)
        mPager.setFadeFactor(0.6f)
    }

    companion object {
        protected val PAGE_TITLES = arrayOf("Page 1", "Page 2",
                "Page 3", "Page 4", "Page 5")
    }
}